//
//  ViewController.m
//  scoralView
//
//  Created by mac on 16-3-4.
//  Copyright (c) 2016年 mac. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (retain, nonatomic) IBOutlet UIScrollView *myScrollView;
- (IBAction)scroll;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    self.myScrollView.contentSize = CGSizeMake(1200, 600);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [_myScrollView release];
    [super dealloc];
}
- (IBAction)scroll {
    //1.获取scrollView的偏移量
    CGPoint imageOffset = self.myScrollView.contentOffset;
    //2.设置偏移值
    CGFloat offsetx = imageOffset.x +30;
    CGFloat offsety = imageOffset.y +30;
    //3.重置scrollview
    self.myScrollView.contentOffset = CGPointMake(offsetx, offsety);
    CGPoint offset = CGPointMake(offsetx, offsety);
    [self.myScrollView setContentOffset:offset animated:YES];
}

@end
